<template>
	<view>
		<web-view @message="message" :src="web_url"></web-view>
	</view>
</template>

<script>
	import {
		Config
	} from '../../common/Config.js'
	export default {
		data() {
			return {
				appid: '',
				wxapp_openid: '',
				project_id: '',
				web_url: ''
			}
		},
		onLoad(options) {
			let that = this;
			// that.web_url = options.web_url;
			// that.appid = options.appid;
			// that.secret = options.secret;
			
			// if(options.device && options.port){
			// 	that.device = options.device;
			// 	that.port = options.port;
			// 	that.web_url = that.url + "?device=" + options.device + "&port=" + options.port + "&applet_openid=" + options.applet_openid + "&appid=" + options.appid + "&secret=" + options.secret;
			// }
			// else if(options.appKey){
			// 	that.appKey = options.appKey;
			// 	that.web_url = that.url + "?appKey=" + options.appKey + "&applet_openid=" + options.applet_openid + "&appid=" + options.appid + "&secret=" + options.secret;
			// }
			uni.showLoading({
				title: '正在授权中'
			});
			if(options.appid){
				that.appid = options.appid;
			}
			if(options.wxapp_openid){
				that.wxapp_openid = options.wxapp_openid;
			}
			if(options.project_id){
				that.project_id = options.project_id;
			}
			var backUrl = Config.api + '/wxlogin/officalcallback?appid='+that.appid+'&wxapp_openid='+that.wxapp_openid+'&project_id='+that.project_id;
			var encodeurl = encodeURIComponent(backUrl);
			var url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + that.appid + "&redirect_uri="
				+ encodeurl + "&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
			console.log(url);
			that.web_url = url;
		},
		methods: {
			message(event){
				console.log(event.detail.data);
			}
		},
	}
</script>

<style>

</style>
